import MUtil from 'util/mm.jsx'
const __mm=new MUtil();

class User{
    login(loginInfo){
        return __mm.request({
                url:"/manage/user/login.do",
                type:'post',
                data:loginInfo
            })

    }
    //检查接口数据是否合法
    checkLoginInfo(loginInfo){
        let username=$.trim(loginInfo.username),
            password=$.trim(loginInfo.password);
        if(typeof loginInfo.username !== 'string' || loginInfo.username.length===0){
            return {
                status:false,
                msg:'用户名不能为空'
            }
        }
        if(typeof loginInfo.password !== 'string' || loginInfo.password.length===0){
            return {
                status:false,
                msg:'密码不能为空'
            }
        }
        return {
            status:true,
            msg:'验证通过'
        }
    }
    // 退出登录
    logout(){
        return __mm.request({
            url:"/user/logout.do",
            type:'post'
        })
    }

    getUserList(pageNum){
        return __mm.request({
            url:"/manage/user/list.do",
            type:'post',
            data:{
                pageNum:pageNum
            }
        })
    }
}

export default User;